package so.shanku.essential.adapter;

import android.content.Context;
import android.content.res.Resources;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import aym.util.json.JsonMap;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import so.shanku.essential.R;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2015/9/16.
 */
public class TopCenterAdapter extends MyBaseAdapter {
    private int selectIndex=0;//ÉèÖÃÑ¡ÖÐÏò

    public int getSelectIndex() {
        return selectIndex;
    }

    public void setSelectIndex(int selectIndex) {
        this.selectIndex = selectIndex;
    }

    public TopCenterAdapter(Context context) {
        super(context);
    }

    public TopCenterAdapter(Context context, List<? extends Map<String, ?>> datas) {
        super(context, datas);
    }


    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder viewHolder = null;
        if (view == null) {
            view = layoutInflater.inflate(R.layout.tv_shopping_top, viewGroup, false);
            viewHolder = new ViewHolder(view);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
         if(selectIndex==i){
             viewHolder.tv_shopping_radiobutton.setSelected(true);
         }
        else{
             viewHolder.tv_shopping_radiobutton.setSelected(false);
         }
        JsonMap data = (JsonMap) datas.get(i);
        viewHolder.tv_shopping_radiobutton.setText(data.getStringNoNull("name"));
        return view;
    }

    public class ViewHolder {
        @ViewInject(R.id.tv_shopping_radiobutton)
        public TextView tv_shopping_radiobutton;

        public ViewHolder(View view) {
            ViewUtils.inject(this, view);
        }

    }
}
